package org.jason.mapmaker.server.service;

import org.jason.mapmaker.model.Feature;
import org.jason.mapmaker.server.repository.FeatureRepository;
import org.jason.mapmaker.shared.exceptions.RepositoryException;
import org.jason.mapmaker.shared.exceptions.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author TSgt Jason Ferguson
 */
@Service("featureService")
public class FeatureServiceImpl implements FeatureService {

    private FeatureRepository featureRepository;

    @Autowired
    public void setFeatureRepository(FeatureRepository featureRepository) {
        this.featureRepository = featureRepository;
    }

    public void persist(Feature object) throws ServiceException {

        try {
            featureRepository.persist(object);
        } catch (RepositoryException e) {
            throw new ServiceException(e);
        }
    }

    public void remove(Feature object) throws ServiceException {

        try {
            featureRepository.remove(object);
        } catch (RepositoryException e) {
            throw new ServiceException(e);
        }
    }
}
